﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using FOModels.BannerSlideShow;
namespace DataAccess.BannerSlideShow
{
    public class BannerSlideShowDAL
    {
        private SQLDataAccess db;
        public BannerSlideShowDAL()
        {
            db = new SQLDataAccess();
        }
        public DataTable getslideshow()
        {
            return db.exeSelect("Select * from SlideShow where Enable = 1 order by OrderSort asc");
        }
        public DataTable getslideshowall()
        {
            return db.exeSelect("Select * from SlideShow ");
        }
        public DataTable getslideshowbyid(int SShowID)
        {
            return db.exeSelect("Select * from SlideShow where SShowID = " + SShowID + "");
        }

        public int InsertSlide(BannerSlideShowModels models)
        {
            return db.exeUpdate("insert into SlideShow(Title,Images,Target,Links,Enable) values(N'" + models.Title + "',N'" + models.Images + "',N'" + models.Target + "',N'" + models.Links + "','" + models.Enable + "')");
        }
        public int UpdateSlide(BannerSlideShowModels models)
        {
            return db.exeUpdate("update SlideShow set Title = N'" + models.Title + "', Images = N'" + models.Images + "', Target = N'" + models.Target + "',Links = N'" + models.Links + "',Enable = '" + models.Enable + "',OrderSort = " + models.OrderSort + " where SShowID = " + models.SShowID + "");
        }
        public int DeleteSlide(int SShowID)
        {
            return db.exeUpdate("Delete from SlideShow where SShowID = " + SShowID + "");
        }


        //EN

        public DataTable getslideshow_EN()
        {
            return db.exeSelect("Select * from SlideShow_EN where Enable = 1 order by OrderSort asc");
        }
        public DataTable getslideshowall_EN()
        {
            return db.exeSelect("Select * from SlideShow_EN");
        }
        public DataTable getslideshowbyid_EN(int SShowID)
        {
            return db.exeSelect("Select * from SlideShow_EN where SShowID = " + SShowID + "");
        }

        public int InsertSlide_EN(BannerSlideShowModels models)
        {
            return db.exeUpdate("insert into SlideShow_EN(Title,Images,Target,Links,Enable) values(N'" + models.Title + "',N'" + models.Images + "',N'" + models.Target + "',N'" + models.Links + "','" + models.Enable + "')");
        }
        public int UpdateSlide_EN(BannerSlideShowModels models)
        {
            return db.exeUpdate("update SlideShow_EN set Title = N'" + models.Title + "', Images = N'" + models.Images + "', Target = N'" + models.Target + "',Links = N'" + models.Links + "',Enable = '" + models.Enable + "',OrderSort = " + models.OrderSort + " where SShowID = " + models.SShowID + "");
        }
        public int DeleteSlide_EN(int SShowID)
        {
            return db.exeUpdate("Delete from SlideShow_EN where SShowID = " + SShowID + "");
        }
    }
}
